
/*
14-8 Modify NameHiding.cpp by adding three overloaded functions named h( ) to Base, and show that redefining one of them in a derived class hides the others.
*/
#include <iostream>
#include <string>
using namespace std;

class Base {
public:
	int f() const { 
		cout << "Base::f()\n"; 
		return 1; 
	}
	int f(string) const { return 1; }
	void g() {}
	
	void h(){
		
	}
	
	void h(int){
		
	}
	
	void h(string){
		
	}
};

class Derived1 : public Base {
public:
	void g() const {}
};

class Derived2 : public Base {
public:
	// Redefinition:
	int f() const { 
		cout << "Derived2::f()\n"; 
		return 2;
	}
	
	void h(){
		cout << "Derived2::h()\n";
	}
};

class Derived3 : public Base {
public:
	// Change return type:
	void f() const { cout << "Derived3::f()\n"; }
};

class Derived4 : public Base {
public:
	// Change argument list:
	int f(int) const { 
		cout << "Derived4::f()\n"; 
		return 4; 
	}
};

int main(){
	Derived2 d2;
	d2.h();
	//error: d2.h(1);
	//error: d2.h('1');
}
